package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.SpikeActiveShop;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商城秒杀商品表 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-08-27
 */
public interface SpikeActiveShopMapper extends BaseAddMapper<SpikeActiveShop> {

    @Select("SELECT\n" +
            " id,\n" +
            " spike_active_id,\n" +
            " shop_id,\n" +
            " spike_active_id,\n" +
            " shop_id,\n" +
            " shop_name,\n" +
            " shop_image,\n" +
            " shop_sku_id,\n" +
            " line_price,\n" +
            " sale_price\n" +
            "FROM\n" +
            " spike_active_shop \n" +
            "WHERE\n" +
            " is_deleted = 0 \n" +
            " AND spike_active_id = #{spikeActiveId}\n" +
            "ORDER BY sort LIMIT 4")
    List<SpikeActiveShop> getSpikeActiveShopByActive(@Param("spikeActiveId") Integer spikeActiveId);

    @Select("SELECT * \n" +
            "FROM\n" +
            " spike_active_shop \n" +
            "WHERE\n" +
            " is_deleted = 0 \n" +
            " AND spike_active_id = #{spikeActiveId}\n" +
            "ORDER BY sort LIMIT 4")
    List<SpikeActiveShop> getPcMainSpikeActiveShopByActive(@Param("spikeActiveId") Integer spikeActiveId);

    @Select("select IFNULL(max(sort)+1,1) as sort from spike_active_shop where is_deleted=0")
    Integer getMaxSort();

   /* @Select("")
    List<SpikeActiveShop> changeOnLineStatusById(@Param("id") Integer id);*/
}
